<template>
  <div class="share-goods">
    <div class="collect" v-if="isItemActivityDetail" @click="showGoodsCode">
      <div class="icon icon-share"></div>
      <div>分享</div>
    </div>
    <div class="collect" @click="showGoodsCode" v-if="isItemActivityDetail">
      <div class="icon"></div>
      <div>分享</div>
    </div>
    <!-- ST 自定义分享 -->
    <god-share-cpt ref="god-share-cpt" @share="shareGoods"></god-share-cpt>
    <!-- 商品分享二维码弹窗 -->
    <goods-code :visible.sync="goodsCodeDialogVisible" :codeData="detailAll && detailAll.qrcode"></goods-code>
  </div>
</template>


<script>
import Vue from "vue";
import GodShareCpt from "@/components/god/god-share";
import goodsCode from "../../../../components/goodsCode";
export default Vue.extend({
  props: {
    detailAll: {
      type: Object,
    },
    isItemActivityDetail: {
      type: Boolean,
    },
  },
  components: {
    GodShareCpt,
    goodsCode,
  },
  data() {
    return {
      goodsCodeDialogVisible: false,
    };
  },
  beforeDestroy() {
    // TODO 页面销毁前销毁所有监听事件
    this.$off()
  },
  methods: {
    // 商品二维码
    showGoodsCode() {
      this.$refs["god-share-cpt"].show(this.detailAll);
    },
    shareGoods() {
      this.goodsCodeDialogVisible = true;
    },
  },
});
</script>

<style></style>